Skip to content

feat: Expanded mode for global drawers #3381

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 78 commits into from
May 21, 2025
Merged

Conversation

georgylobko
Copy link
Member

@georgylobko georgylobko commented Mar 26, 2025

Description

Focus (expanded) mode for global drawers

  • One click expand and collapse on global panel/drawer
  • Preserve previous state of panels when leaving focus mode.
  • When opening a any panel the page leaves focus mode
  • When accessing a local panel from the toolbar we leave focus mode

qkaB4Ap1KSFox

Related links, issue #, if available: n/a

How has this been tested?

Unit / integ tests.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Copy link

codecov bot commented Mar 28, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 96.55%. Comparing base (b5e054e) to head (6b51173).
Report is 2 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main    #3381    +/-   ##
========================================
  Coverage   96.54%   96.55%            
========================================
  Files         807      807            
  Lines       23390    23450    +60     
  Branches     7708     8172   +464     
========================================
+ Hits        22581    22641    +60     
+ Misses        802      755    -47     
- Partials        7       54    +47     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@georgylobko georgylobko changed the title feat: Focus mode for global drawers feat: Expanded mode for global drawers Apr 2, 2025
@georgylobko georgylobko marked this pull request as ready for review May 19, 2025 16:48
@georgylobko georgylobko requested a review from a team as a code owner May 19, 2025 16:48
@georgylobko georgylobko requested review from pan-kot and just-boris and removed request for a team May 19, 2025 16:48
Copy link
Member

@just-boris just-boris left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Legend:

  • ⛳ – red flag, aka important to address
  • 💬 – just a comment, for your consideration

@@ -318,6 +318,7 @@ export namespace AppLayoutProps {
triggerButton?: string;
resizeHandle?: string;
resizeHandleTooltipText?: string;
expandedModeButton?: string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛳ How about splitting this interface in two separate for local and global drawer labels?

Also, global drawers cannot be set using React API, so we should not expose this interface here

@@ -64,10 +68,14 @@ function AppLayoutGlobalDrawerImplementation({
const size = getLimitedValue(minDrawerSize, activeDrawerSize, maxDrawerSize);
const lastOpenedDrawerId = drawersOpenQueue.length ? drawersOpenQueue[0] : null;
const hasTriggerButton = !!activeGlobalDrawer?.trigger;
const animationDisabled = activeGlobalDrawer?.defaultActive && !drawersOpenQueue.includes(activeGlobalDrawer.id);
const isExpanded = activeGlobalDrawer?.isExpandable && expandedDrawerId === activeDrawerId;
const isExpandedPrevious = usePrevious(isExpanded);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 isExpandedPrevious can be called simpler - wasExpanded

data-testid={`awsui-app-layout-drawer-content-${activeDrawerId}`}
>
{!isMobile && activeGlobalDrawer?.isExpandable && (
<div className={styles['drawer-expanded-mode-button']}>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛳ Creating grid layout column and manual position does not really scale.

Can we create a single "drawer buttons" wrapper that contains all current and future button additions?

iconName={isExpanded ? 'shrink' : 'expand'}
onClick={() => setExpandedDrawerId(isExpanded ? undefined : activeDrawerId)}
variant="icon"
analyticsAction={isExpanded ? 'expand' : 'collapse'}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛳ Did you check with @fralongo if this analytics action is already supported on the receivers' end?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. We don't need to do anything else on our end

@@ -72,6 +73,17 @@
}
}
}

&.drawer-expanded-mode {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛳ "Skeleton layout" was supposed to be a very abstract implementation of the layout.

When expanded mode needs such heavy changes here, how do you expect it to widgetize and maintain in the future?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how do you expect it to widgetize and maintain in the future?

Skeleton styles (this scss file) as well as its attributes (classNames based on component props) and app layout state will be widgetized, so that such changes will be delivered without merging from live.

export default function WithDrawers() {
const { urlParams, setUrlParams } = useContext(AppContext as DemoContext);
const hasTools = urlParams.hasTools ?? true;
const appLayoutRef = useRef<AppLayoutProps.Ref>(null);
Copy link
Member

@just-boris just-boris May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 This value is never used

splitPanel={
<SplitPanel
header="Overview"
i18nStrings={{
Copy link
Member

@just-boris just-boris May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Do we really have no reusable strings for this already?

test(
'should show only expanded drawer and hide all other panels if expanded mode for a drawer is active',
setupTest(async page => {
await page.setWindowSize({ ...viewports.desktop, width: 1600 });
Copy link
Member

@just-boris just-boris May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 There are several places with this 1600 width already

Is this time to create a new viewports constant, something like "width to fit 3 side-by-side drawers"

@@ -60,4 +60,6 @@ export interface AppLayoutInternals {
onActiveDrawerResize: (detail: { id: string; size: number }) => void;
onActiveGlobalDrawersChange: (newDrawerId: string, params: OnChangeParams) => void;
splitPanelAnimationDisabled?: boolean;
expandedDrawerId: string | undefined;
Copy link
Member

@just-boris just-boris May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛳ For widget compatibility, do we want to use null as "no drawer expanded" and then undefined as "we got an older version with this field not yet defined"

});
const { wrapper, globalDrawersWrapper } = await renderComponent(<AppLayout />);

await delay();
Copy link
Member

@just-boris just-boris May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Why is there an extra delay? Was the delay inside await renderComponent() not enough?

@georgylobko georgylobko added this pull request to the merge queue May 21, 2025
Merged via the queue into main with commit 727c496 May 21, 2025
66 of 67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants